#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;

using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;
using Agresso.Interface.Layer.Domain;

#endregion

namespace Agresso.Interface.Layer.Web
{
    public partial class ListViewColumnForm : Form
    {
        ListView m_listview;
        User m_user;
        public ListViewColumnForm(ListView v, User user)
        {
            InitializeComponent();
            m_listview = v;
            m_user = user;
            foreach(ColumnHeader ch in v.Columns)
            {
                int i = listBox1.Items.Add(ch.Name);
                if (ch.Visible)
                    listBox1.SelectedIndex = i;
            }
        }

        private void listBox1_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItems.Count == 0) return;
            foreach (ColumnHeader ch in m_listview.Columns)
            {
                ch.Visible = false;
            }
            foreach (int i in listBox1.SelectedIndices)
            {
                m_listview.Columns[i].Visible = true;
            }
            
        }

        private void ListViewColumnForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            ListViewTools.SaveConfiguration(m_listview, m_user);
        }
    }
}